window.onload = function() {
	//下一页按钮所在的div
	var wrap = document.getElementById("wrap");
	touch.on(wrap,"touchstart",function(e){
		var  event1=window.event||e;
//		event1.preventDefault();
	})
	touch.on(wrap,"swipeup",function(e){
		location.href = "four.html";
	});
	touch.on(wrap,"swipedown",function(e){
		location.href = "second.html";
	});
	
	
	var img1 = document.getElementById("img1");
	var img2 = document.getElementById("img2");
	var img3 = document.getElementById("img3");
	var img4 = document.getElementById("img4");
	var img5 = document.getElementById("img5");
	var img6 = document.getElementById("img6");
	var img7 = document.getElementById("img7");
	var img8 = document.getElementById("img8");
	var 	wrap=document.getElementById("wrap");
	
	var speed=1;
	move(img1);
	move(img2);
	move(img3);
	move(img4);
	move(img5);
	move(img6);
	move(img7);
	move(img8);
//	
	 
	
	

};
//封装函数,小块移动
function move(img){
	var wrapW=wrap.offsetWidth;
	var speed=Math.random();
	var leftV = img.offsetLeft;
	var topV = img.offsetTop;
	var a=leftV;
	var b=topV;
	var speedx=random(0,1)?1:-1;
	var speedy=random(0,1)?1:-1;
	var timer = setInterval(function() {
		
		
		
		if(leftV/wrapW<=(a/wrapW-0.03)||leftV/wrapW>=(a/wrapW+0.03)){
			speedx=speedx*(-1);
			speedy=speedy*(-1);
		}
		leftV -= speed*speedx;
		topV -=speed*speedy;
		img.style.left = leftV + "px";
		img.style.top = topV + "px";
		
	}, 50);
		
		
		
};
//封装一个数,可能是正也可能是负
function random(m,n){
	
	return Math.floor(Math.random()*(n-m+1)+m)
	
}









